package cn.lysj.framework.foodv2.repository;

import cn.lysj.framework.base.BaseRepository;
import cn.lysj.framework.common.utils.web.SelectItem;
import cn.lysj.framework.foodv2.domain.Food;
import cn.lysj.framework.foodv2.vo.FoodListVo;
import cn.lysj.framework.foodv2.vo.FoodSaleVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


/**
 * @author drj
 * @description 支付宝用户数据处理层
 * @create 2018-11-09 11:20:17
 **/
public interface FoodRepository extends BaseRepository<Food> {


    @Query(value = "select new cn.lysj.framework.foodv2.vo.FoodSaleVo(c.name,c.actSellNum) from FoodTypeAndFoodContact a ,FoodType b , Food c where b.storeId = ?1 and a.foodId = c.id and a.foodTypeId = b.id order by c.actSellNum desc")
    List<FoodSaleVo> findFoodSale(String storeId);

    @Query(value = "SELECT NEW  cn.lysj.framework.common.utils.web.SelectItem(c.id,c.name) FROM FoodTypeAndFoodContact a ,FoodType b , Food c where b.storeId = ?1 and a.foodId = c.id and a.foodTypeId = b.id ")
    List<SelectItem> findFoods(String storeId);



}